
package com.sec.android.app.myfiles.feature.knox;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;

import com.sec.android.app.myfiles.feature.KnoxMgr;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.util.SemFwWrapper;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class KnoxImp {
    protected Context mContext = null;
    private int[] mContainerArray = new int[KnoxMgr.TYPE_MAX];

    public KnoxImp(Context context) {
        mContext = context;
    }

    public boolean isLightWeightContainer() {
        boolean bRet = false;
        return bRet;
    }

    protected List<String> getPathList(List<FileRecord> srcList) {
        List<String> ret = new ArrayList<>();
        if (srcList != null && !srcList.isEmpty()) {
            for (FileRecord record : srcList) {
                if (record.isDirectory()) {
                    File file = SemFwWrapper.file(record.getFullPath());
                    getSubPathList(file, ret);
                }
                String path = record.getFullPath();
                if (!TextUtils.isEmpty(path)) {
                    ret.add(path);
                }
            }
        }
        return ret;
    }

    private List<String> getDestPathList(FileRecord fileRecord, List<String> srcPathList, String destPath) {
        String originalPath = fileRecord.getPath();
        List<String> ret = new ArrayList<>();
        for (String path : srcPathList) {
            String target = path.replaceFirst(originalPath, destPath);
            ret.add(target);
        }
        return ret;
    }

    private void getSubPathList(File file, List<String> srcPathList) {
        File files[] = file.listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.isDirectory()) {
                    getSubPathList(f, srcPathList);
                }
                srcPathList.add(f.getAbsolutePath());
            }
        }
    }

    private int getContainerType(Bundle item) {
        int ret = -1;
        if (item != null) {
            ret = item.getInt("com.sec.knox.moveto.containerType");
        }
        return ret;
    }

    private int getContainerId(Bundle item) {
        int ret = -1;
        if (item != null) {
            ret = item.getInt("com.sec.knox.moveto.containerId");
        }
        return ret;
    }


    public boolean startMoveFiles(ArrayList<FileRecord> srcList, String destPath, int type) {
        boolean bRet = false;
        return bRet;
    }

    public boolean isKnoxModeOn() {
        boolean bRet = false;
        return bRet;
    }

    public boolean isSupportMove() {
        boolean bRet = false;
        return bRet;
    }

    public boolean isSecureFolder() {
        boolean bRet = false;
        return bRet;
    }


    public boolean isInstallSecureFolder() {
        boolean bRet = false;
        return bRet;
    }

    public String getKnoxName(int type) {
        String name = null;
        return name;
    }

    private int convertType(int type) {
        int bRet = 0;
        return bRet;
    }
}